<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>parseformat | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>parseformat</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>parseformat</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/plugins/parseformat/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/10-plugins/14-parseformat.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">npm install moment-parseformat
</code></pre>

							</div>
<p>&#x8BE5;&#x63D2;&#x4EF6;&#x63D0;&#x53D6;&#x65E5;&#x671F;/&#x65F6;&#x95F4;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x683C;&#x5F0F;&#x3002;</p>
<pre><code class="language-javascript">var format = moment.parseFormat(&apos;Thursday, February 6th, 2014 9:20pm&apos;);
// dddd, MMMM Do, YYYY h:mma
moment().format(format); // &#x683C;&#x5F0F;&#x5316;
</code></pre>
<p>&#x8FD9;&#x6837;&#x5C31;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x667A;&#x80FD;&#x65E5;&#x671F;&#x8F93;&#x5165;&#xFF0C;&#x8BA9;&#x7528;&#x6237;&#x8BBE;&#x7F6E;&#x65E5;&#x671F;/&#x65F6;&#x95F4;&#xFF0C;&#x5E76;&#x63D0;&#x53D6;&#x7528;&#x6237;&#x7684;&#x9996;&#x9009;&#x683C;&#x5F0F;&#x4EE5;&#x4F9B;&#x5C06;&#x6765;&#x4F7F;&#x7528;&#x3002;
&#x5728; <a href="javascript:window.open('http://nodejs.cn/s/fpaiJj');" target="_blank" rel="nofollow">minutes.io</a> &#x4E0A;&#x627E;&#x5230;&#x5176;&#x7528;&#x6CD5;&#x793A;&#x4F8B;&#x3002;</p>
<p>&#x8BE5;&#x63D2;&#x4EF6;&#x7531; <a href="javascript:window.open('http://nodejs.cn/s/VtQVrz');" target="_blank" rel="nofollow">@gr2m</a> &#x7F16;&#x5199;&#x3002;
&#x94FE;&#x63A5;&#xFF1A;<a href="javascript:window.open('http://nodejs.cn/s/RwsMtk');" target="_blank" rel="nofollow">&#x6F14;&#x793A;</a> | <a href="javascript:window.open('http://nodejs.cn/s/gioAiD');" target="_blank" rel="nofollow">&#x6E90;&#x4EE3;&#x7801;</a>&#x3002;</p>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">npm install moment-parseformat
</code></pre>

							</div>
<p>This plugin extracts the format of a date/time string.</p>
<pre><code class="language-javascript">var format = moment.parseFormat(&apos;Thursday, February 6th, 2014 9:20pm&apos;);
// dddd, MMMM Do, YYYY h:mma
moment().format(format); // format
</code></pre>
<p>That allows to create smart date inputs that let your users set a
Date/Time and lets you extract the user&apos;s preferred format for future usage.
Find an example usage of it at <a href="javascript:window.open('https://minutes.io/new/Meeting');" target="_blank" rel="nofollow">minutes.io</a>.</p>
<p>The Plugin has been authored by <a href="javascript:window.open('https://github.com/gr2m');" target="_blank" rel="nofollow">@gr2m</a>.
Links: <a href="javascript:window.open('http://gr2m.github.io/moment-parseformat/');" target="_blank" rel="nofollow">Demo</a> |
<a href="javascript:window.open('https://github.com/gr2m/moment.parseFormat');" target="_blank" rel="nofollow">Source</a></p>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>